package easy;

import org.junit.Test;

public class a378_字符串中的第一个唯一字符 {
    public int firstUniqChar(String s) {
        if (s.length() == 0) {
            return -1;
        }
        int[] counts = new int[128];
        char[] chars = s.toCharArray();

        for (int i = 0; i < chars.length; i++) {
          counts[chars[i] - 'a']++;
            int x=chars[i]-'a';
            System.out.println(x);
        }
        for(int j=0;j<s.length();j++){
            if(counts[chars[j]-'a']==1){
                return j;
            }
        }
        return -1;
    }
    @Test
    public void tets(){
        String s="abcdefghigklmnopqrstuvwxyz";
        firstUniqChar(s);
    }
}
